/*
 * 物料信息交易
 * 参数   交易码：trancode=12130
 * 
 */

package org.ccams.tran;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.ccams.domain.TProvider;
import org.ccams.util.PageParameter;

public class Tran11120 extends AbstractJsonTran {

	@SuppressWarnings("unchecked")
	public void buildJSONObject(Map model, JSONObject json,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		int limit = Integer.parseInt(request.getParameter("limit"));
		int start = Integer.parseInt(request.getParameter("start"));
		PageParameter page = new PageParameter();
		page.setLimit(limit);
		page.setStart(start);
		HashMap<String, Object> jsonMap = new HashMap<String, Object>();
		ArrayList<TProvider> al = new ArrayList<TProvider>();
		List<TProvider> list = getCcamsService().getTproviderDao().getTProvider(page);
		int count = getCcamsService().getTmaterielDao().getCount(page);
		
		for(TProvider t : list){
			TProvider u = new TProvider();
			u.setId(t.getId());
			u.setUnitno(t.getUnitno());
			u.setUname(t.getUname());
			u.setCorporator(t.getCorporator());
			u.setTelephone(t.getTelephone());
			u.setMobile(t.getMobile());
			u.setFax(t.getFax());
			u.setEmail(t.getEmail());
			u.setAddr(t.getAddr());
			u.setPostcode(t.getPostcode());
			u.setWwwaddr(t.getWwwaddr());
			u.setLinker(t.getLinker());
			u.setLinkertel(t.getLinkertel());
			u.setLinkermobile(t.getLinkermobile());
			u.setLinkerfax(t.getLinkerfax());
			u.setLinkeremail(t.getLinkeremail());
			u.setLinkerdept(t.getLinkerdept());
			u.setFactoryaddr(t.getFactoryaddr());
			u.setTicketaddr(t.getTicketaddr());
			u.setRgefund(t.getRgefund());
			u.setProdvalue(t.getProdvalue());
			u.setFacttel(t.getFacttel());
			u.setFactlinker(t.getFactlinker());
			u.setRegdate(t.getRegdate());
			u.setPid(t.getPid());
			u.setAccbank(t.getAccbank());
			u.setAccuser(t.getAccuser());
			u.setAccno(t.getAccno());
			u.setAcctel(t.getAcctel());
			u.setTaxno(t.getTaxno());
			u.setPaykind(t.getPaykind());
			u.setCredit(t.getCredit());
			u.setMainmate(t.getMainmate());
			u.setTrafficdate(t.getTrafficdate());
			u.setServicedate(t.getServicedate());
			u.setPactno(t.getPactno());
			u.setJzdate(t.getJzdate());
			u.setJzperiod(t.getJzperiod());
			u.setRemark(t.getRemark());
			u.setModipid(t.getModipid());
			u.setModidate(t.getModidate());
			al.add(u);
		}
		JSONArray JsonArray = JSONArray.fromObject(al); //得到JSON数组 
		jsonMap.put("totalProperty", count);
        jsonMap.put("root", JsonArray);
        json.putAll(jsonMap);
	}
}
